package com.ysd.lis.controller.sta;


import com.ysd.common.Result;
import com.ysd.lis.controller.pub.BaseController;
import com.ysd.lis.dto.UploadCipherText;
import com.ysd.lis.dto.sta.StaModuleDto;
import com.ysd.lis.dto.sta.StaModuleParam;
import com.ysd.lis.entity.SysMenuLog;
import com.ysd.lis.entity.sta.StaModule;
import com.ysd.lis.service.SysMenuLogService;
import com.ysd.lis.service.SysModuleLogService;
import com.ysd.lis.service.sta.StaModuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * cold_chain.sys_module 前端控制器
 * </p>
 *
 * @author prs
 * @since 2024-12-18
 */
@Api(tags = "模块管理")
@RestController
@RequestMapping("/lis/sta/staModule")
public class StaModuleController extends BaseController {

    @Autowired
    StaModuleService staModuleService;

    @Autowired
    SysModuleLogService sysModuleLogService;
    @Autowired
    SysMenuLogService sysMenuLogService;

    @ApiOperation("不分页查询")
    @GetMapping("/findStaModuleList")
    public Result findStaModuleList(StaModuleParam param){
        return staModuleService.findStaModuleList(param);
    }

    @ApiOperation("新增")
    @PostMapping("/addStaModule")
    public Result addStaModule(@RequestBody StaModule staModule){
        return  staModuleService.addStaModule(staModule);
    }

    @ApiOperation("修改")
    @PostMapping("/editStaModule")
    public Result editStaModule(@RequestBody StaModule supplier) {
        return staModuleService.editStaModule(supplier);
    }

    @ApiOperation("批量删除")
    @PostMapping("/batchDeleteStaModuleList")
    public Result batchDeleteStaModuleList(@RequestBody StaModuleDto dto){
        return  staModuleService.batchDeleteStaModuleList(dto);
    }


    @ApiOperation("查看模块日志表")
    @GetMapping("/findSysModuleLogList")
    public Result findSysModuleLogList(@RequestParam(required = false) String state){
        return sysModuleLogService.findSysModuleLogList(state);
    }

    @ApiOperation("查看菜单日志表")
    @GetMapping("/findSysMenuLogList")
    public Result findSysMenuLogList(String modCode){
        return sysMenuLogService.findSysMenuLogList(modCode);
    }

    /***
     * 上传注册码
     *
     */
    @ApiOperation("上传检测标准附件")
    @PostMapping("/uploadRegisterFile")
    public Result uploadRegisterFile(@RequestParam(value = "file") MultipartFile file, HttpServletRequest request) throws Exception {
        return  staModuleService.uploadRegisterFile(file,request);
    }

    @ApiOperation("上传密文")
    @PostMapping("/uploadRegisterCipherText")
    public Result uploadRegisterCipherText(@RequestBody UploadCipherText uploadCipherText) throws Exception {
        return  staModuleService.uploadRegisterCipherText(uploadCipherText);
    }

}
